import request from '@/utils/request'


export function login(_this) {
    return request({
        url: 'http://localhost:8080/api/user/login',
        method: 'post',
        data: _this.user
    }).then((res) => {
        console.log(res);
        if (res.data.code === 200) {
            sessionStorage.setItem("userInfo", JSON.stringify(res.data.data.userInfo));
            if (res.data.data.gid === 1) {
                location.href = "/declare/admin/userList";
            } else if (res.data.data.gid === 2) {
                location.href = "/declare/expert/index";
            } else {
                location.href = "/declare/unit/index";
            }
        } else {
            alert("登录失败");
        }
    })
}

